package com.chen.boot.config;

import com.alibaba.fastjson.JSON;
import com.chen.im.view.ChatList;

import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

/**
 * @Description 系统全局监听器
 * @Author Pengwei
 * @CreatDate 2021/11/17 20:48
 */
@Slf4j
@Component
public class GlobalListener {

    public static GlobalListener instance;

    public GlobalListener() {
        this.instance = this;
    }

    /**
     * @param globalType
     * @param event
     */
    public void listenerEvent(GlobalType globalType, Object event) {
        if (globalType.equals(GlobalType.received)) {
            ChatList.items.add(JSON.toJSONString(event));
            log.debug(JSON.toJSONString(event));
        }
    }
}
